#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

void quickSort(vector<int>& v, int l, int r)
{
    int start = l;
    int end = r;
    if(start<end)
    {   
        int pov=v[l];
        while(l<r)
        {
            while(v[r]>=pov&&r>l)
                r--;
            v[l]=v[r];
            while(v[l]<=pov&&r>l)
                l++;
            v[r]=v[l];
        }
        v[l]=pov;
        cout<<"arryed list: "<<endl;
        for(int i=0;i<v.size();i++)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
        quickSort(v,start,l-1);
        quickSort(v,l+1,end);
    }
}
int main()
{
    cout<<"Enter the numbers:"<<endl;
    vector<int> v;
    int n;
    while(n!=-1)
    {
        cin>>n;
        v.push_back(n);
    }
    v.pop_back();
    quickSort(v,0,v.size()-1);
    cout<<"Sorted array:"<<endl;
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    return 0;
}